1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
---
// 月別・年度別アーカイブ(/kodaira/events/2026-11/、/kodaira/events/r8/ など)。
// 行事予定のデータ(src/data/schedule/*.json)から、その期間の予定だけを静的に生成する。
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
import ScheduleTable from '@/components/ScheduleTable.astro';
import {
fiscalYearKeys,
fiscalYearLabel,
fiscalYearOf,
monthCounts,
monthKeys,
monthLabel,
monthsInFiscalYear,
rowsInFiscalYear,
rowsInMonth,
} from '@/lib/schedule-months';
import { SCHEDULE_BASE_PATH } from '@/data/schedule/config';
export function getStaticPaths() {
return [
...monthKeys.map((key, i) => ({
params: { period: key },
props: {
kind: 'month' as const,
key,
prev: monthKeys[i - 1] ?? null,
next: monthKeys[i + 1] ?? null,
},
})),
...fiscalYearKeys.map((key, i) => ({
params: { period: key },
props: {
kind: 'fiscal' as const,
key,
prev: fiscalYearKeys[i - 1] ?? null,
next: fiscalYearKeys[i + 1] ?? null,
},
})),
];
}
const { kind, key, prev, next } = Astro.props as {
kind: 'month' | 'fiscal';
key: string;
prev: string | null;
next: string | null;
};
const label = kind === 'fiscal' ? fiscalYearLabel(key) : monthLabel(key);
const periodLabel = (period: string) =>
kind === 'fiscal' ? fiscalYearLabel(period) : monthLabel(period);
const meetingRows =
kind === 'fiscal' ? rowsInFiscalYear(key, 'meeting') : rowsInMonth(key, 'meeting');
const eventRows =
kind === 'fiscal' ? rowsInFiscalYear(key, 'event') : rowsInMonth(key, 'event');
// 年度ページでは、その年度の月別ページへの一覧も並べる。
const months = kind === 'fiscal' ? monthsInFiscalYear(key) : [];
const url = (period: string) => `${SCHEDULE_BASE_PATH}${period}/`;
// 期間がすべて過去か、すべて未来か、今日を含むかで説明文を変える。
// (過去の月に「今後の予定です」と書いたり、未来の月に「終了分も掲載」と書いたりしない)
const pad = (n: number) => String(n).padStart(2, '0');
const now = new Date();
const currentMonth = `${now.getFullYear()}-${pad(now.getMonth() + 1)}`;
const periodMonths = kind === 'fiscal' ? monthsInFiscalYear(key) : [key];
const firstMonth = periodMonths[0] ?? key;
const lastMonth = periodMonths[periodMonths.length - 1] ?? key;
const isAllPast = lastMonth < currentMonth;
const isAllFuture = firstMonth > currentMonth;
const lead = isAllPast
? `${label}の小平市のイベントと、審議会等・市議会の予定を、記録として掲載しています。`
: isAllFuture
? `${label}の小平市のイベントと、審議会等・市議会の開催予定です。`
: `${label}の小平市のイベントと、審議会等・市議会の開催予定です。開催日が過ぎたものもあわせて掲載しています。`;
const caution = isAllPast
? '掲載内容は、掲載時点のものです。'
: '変更になることがありますので、各問い合わせ先へご確認ください。';
const description = isAllPast
? `${label}に開催された小平市のイベントと、審議会・市議会の予定の記録です。日程・会場を確認できます。`
: `${label}の小平市のイベントと、審議会・市議会の開催予定の一覧です。日程・会場・申込期限を確認できます。`;
---
<StarlightPage
frontmatter={{
title: `小平市のイベント・行事予定(${label})`,
description,
}}
>
<p><a href={SCHEDULE_BASE_PATH}>← 小平市のイベント・行事予定カレンダー(今後)に戻る</a></p>
<p>{lead}{caution}</p>
{
kind === 'fiscal' && (
<ul class="schedule-month-archive">
{months.map((month) => (
<li>
<a href={url(month)}>{monthLabel(month)}の予定</a>
<span class="schedule-month-count">{monthCounts[month]}件</span>
</li>
))}
</ul>
)
}
{
meetingRows.length > 0 && (
<>
<h2>審議会等・市議会の開催予定</h2>
<div class="schedule-table schedule-table--date-nowrap">
<ScheduleTable variant="meeting" rows={meetingRows} />
</div>
</>
)
}
{
eventRows.length > 0 && (
<>
<h2>イベント</h2>
<div class="schedule-table">
<ScheduleTable variant="event" rows={eventRows} />
</div>
</>
)
}
{
kind === 'month' && (
<p class="schedule-fiscal-link">
<a href={url(fiscalYearOf(key))}>{fiscalYearLabel(fiscalYearOf(key))}の予定をまとめて見る</a>
</p>
)
}
<nav class="schedule-month-nav" aria-label={kind === 'fiscal' ? '年度の移動' : '月の移動'}>
{prev ? <a href={url(prev)}>← {periodLabel(prev)}</a> : <span />}
{next ? <a href={url(next)}>{periodLabel(next)} →</a> : <span />}
</nav>
</StarlightPage>
|